package com.acme.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.Valid;
import javax.validation.constraints.Size;
import javax.validation.groups.Default;

import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;

@Entity
@Indexed
@Table(name="claims")
public class Claim {
	
	@Id @GeneratedValue
	@Column(name = "id")
	private int claimID;
	
	@ManyToOne
	@JoinColumn(name = "userId")
	@Valid
	private User user;
	
	@Column(name = "type")
	@Field
	@NotEmpty (message="Cannot be empty.", groups = {Default.class, InjuryInfoValidation.class})
	private String type;
	
	@Column(name = "date")
	@Field
	@NotBlank (message="Cannot be empty.", groups = {Default.class, InjuryInfoValidation.class})
	private String date;
	
	@Column(name = "jobRelated")
	@Field
	private boolean jobRelated;
	
	@Column(name = "hospitalized")
	@Field
	private boolean hospitalized;
	
	@Column(name = "hospitalName")
	@Field
	//@NotBlank (message="Cannot be empty.", groups = {Default.class, HospitalInfoValidation.class})
	@Size(message="Cannot exceed 30 characters.", max=30, groups = {Default.class, HospitalInfoValidation.class})
	private String hospitalName;
	
	@Column(name = "admittingPhysician")
	@Field
	//@NotBlank (message="Cannot be empty.", groups = {Default.class, HospitalInfoValidation.class})
	@Size(message="Cannot exceed 30 characters.", max=30, groups = {Default.class, HospitalInfoValidation.class})
	private String admittingPhysician;
	
	@Column(name = "hospAdmitDate")
	@Field
	//@NotBlank (message="Cannot be empty.", groups = {Default.class, HospitalInfoValidation.class})
	private String hospAdmitDate;
	
	@Column(name = "hospDischargeDate")
	@Field
	//@NotBlank (message="Cannot be empty.", groups = {Default.class, HospitalInfoValidation.class})
	private String hospDischargeDate;
	
	@Column(name = "diagnosis")
	@Field
	@NotBlank (message="Cannot be blank.", groups = {Default.class, HospitalInfoValidation.class, InjuryInfoValidation.class})
	@Size(message="Cannot exceed 300 characters.", max=300, groups = {Default.class, HospitalInfoValidation.class, InjuryInfoValidation.class})
	private String diagnosis;
	
	@Column(name = "medicare")
	@Field
	private boolean medicare;
	
	@Column(name = "medicareNumber")
	@Field
	//@NotBlank (message="Cannot be blank.", groups = {Default.class, MedicareValidation.class})
	@Size(message="Cannot exceed 20 characters.", max=20, groups = {Default.class, MedicareValidation.class})
	private String medicareNumber;
	
	@Column(name = "medicareA")
	@Field
	private boolean medicareA;
	
	@Column(name = "medicareB")
	@Field
	private boolean medicareB;
	
	@Column(name = "otherInsurance")
	@Field
	private boolean otherInsurance;
	
	@Column(name = "otherInsCompanyName")
	@Field
	//@NotBlank (message="Cannot be blank.", groups = {Default.class, PrivateValidation.class})
	@Size(message="Cannot exceed 40 characters.", max=40, groups = {Default.class, PrivateValidation.class})
	private String otherInsCompName;
	
	@Column(name = "otherInsCompId")
	@Field
//	@NotBlank (message="Cannot be blank.", groups = {Default.class, PrivateValidation.class})
//	@Size(message="Cannot exceed 20 characters.", max=20, groups = {Default.class, PrivateValidation.class})
	private int otherInsCompID;
	
	@Column(name = "status")
	@Field
	private String status;
	
	@Column(name = "eSignature")
	@Field
	private boolean eSignature;
	
	public Claim() {
	}
	
	public Claim(User user, String type, String date,
			boolean jobRelated, boolean hospitalized, String hospitalName,
			String admittingPhysician, String hospAdmitDate,
			String hospDischargeDate, String diagnosis, boolean medicare,
			String medicareNumber, boolean medicareA, boolean medicareB,
			boolean otherInsurance, String otherInsCompName,
			int otherInsCompID, String status, boolean eSignature) {
		super();
		this.user = user;
		this.type = type;
		this.date = date;
		this.jobRelated = jobRelated;
		this.hospitalized = hospitalized;
		this.hospitalName = hospitalName;
		this.admittingPhysician = admittingPhysician;
		this.hospAdmitDate = hospAdmitDate;
		this.hospDischargeDate = hospDischargeDate;
		this.diagnosis = diagnosis;
		this.medicare = medicare;
		this.medicareNumber = medicareNumber;
		this.medicareA = medicareA;
		this.medicareB = medicareB;
		this.otherInsurance = otherInsurance;
		this.otherInsCompName = otherInsCompName;
		this.otherInsCompID = otherInsCompID;
		this.status = status;
		this.eSignature = eSignature;
	}

//	public int getUserID() {
//		return userID;
//	}
//
//	public void setUserID(int userID) {
//		this.userID = userID;
//	}

	public int getClaimID() {
		return claimID;
	}

	public void setClaimID(int claimID) {
		this.claimID = claimID;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public boolean isJobRelated() {
		return jobRelated;
	}

	public void setJobRelated(boolean jobRelated) {
		this.jobRelated = jobRelated;
	}

	public boolean isHospitalized() {
		return hospitalized;
	}

	public void setHospitalized(boolean hospitalized) {
		this.hospitalized = hospitalized;
	}

	public String getHospitalName() {
		return hospitalName;
	}

	public void setHospitalName(String hospitalName) {
		this.hospitalName = hospitalName;
	}

	public String getAdmittingPhysician() {
		return admittingPhysician;
	}

	public void setAdmittingPhysician(String admittingPhysician) {
		this.admittingPhysician = admittingPhysician;
	}

	public String getHospAdmitDate() {
		return hospAdmitDate;
	}

	public void setHospAdmitDate(String hospAdmitDate) {
		this.hospAdmitDate = hospAdmitDate;
	}

	public String getHospDischargeDate() {
		return hospDischargeDate;
	}

	public void setHospDischargeDate(String hospDischargeDate) {
		this.hospDischargeDate = hospDischargeDate;
	}

	public String getDiagnosis() {
		return diagnosis;
	}

	public void setDiagnosis(String diagnosis) {
		this.diagnosis = diagnosis;
	}

	public boolean isMedicare() {
		return medicare;
	}

	public void setMedicare(boolean medicare) {
		this.medicare = medicare;
	}

	public String getMedicareNumber() {
		return medicareNumber;
	}

	public void setMedicareNumber(String medicareNumber) {
		this.medicareNumber = medicareNumber;
	}

	public boolean isMedicareA() {
		return medicareA;
	}

	public void setMedicareA(boolean medicareA) {
		this.medicareA = medicareA;
	}

	public boolean isMedicareB() {
		return medicareB;
	}

	public void setMedicareB(boolean medicareB) {
		this.medicareB = medicareB;
	}

	public boolean isOtherInsurance() {
		return otherInsurance;
	}

	public void setOtherInsurance(boolean otherInsurance) {
		this.otherInsurance = otherInsurance;
	}

	public String getOtherInsCompName() {
		return otherInsCompName;
	}

	public void setOtherInsCompName(String otherInsCompName) {
		this.otherInsCompName = otherInsCompName;
	}

	public int getOtherInsCompID() {
		return otherInsCompID;
	}

	public void setOtherInsCompID(int otherInsCompID) {
		this.otherInsCompID = otherInsCompID;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public boolean iseSignature() {
		return eSignature;
	}

	public void seteSignature(boolean eSignature) {
		this.eSignature = eSignature;
	}
	
	public void submitClaim() {
		// Submits a user's health insurance claim for approval
	}
	
	public void approveClaim() {
		// Approves a user's claim, informs user
	}
	
	public void denyClaim() {
		// Denies a user's claim, informs user;
	}
	
	public interface UserValidation {};
	public interface InjuryInfoValidation {};
	public interface HospitalInfoValidation {};
	public interface MedicareValidation {};
	public interface PrivateValidation {}
	
	@Override
	public String toString() {
		return "Claim [claimID=" + claimID + ", user=" + user + ", type="
				+ type + ", date=" + date + ", jobRelated=" + jobRelated
				+ ", hospitalized=" + hospitalized + ", hospitalName="
				+ hospitalName + ", admittingPhysician=" + admittingPhysician
				+ ", hospAdmitDate=" + hospAdmitDate + ", hospDischargeDate="
				+ hospDischargeDate + ", diagnosis=" + diagnosis
				+ ", medicare=" + medicare + ", medicareNumber="
				+ medicareNumber + ", medicareA=" + medicareA + ", medicareB="
				+ medicareB + ", otherInsurance=" + otherInsurance
				+ ", otherInsCompName=" + otherInsCompName
				+ ", otherInsCompID=" + otherInsCompID + ", status=" + status
				+ ", eSignature=" + eSignature + "]";
	};
	
}
